<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>Hello APP</title>
<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../../css/common.css" />
<style>
	#header {
		visibility: hidden;
	}
	#footer {
		background-color: #FFF;
		height: 2.5rem;
	}
	.recommend {
		width: 4rem;
		text-align: center;
	}
	.recommend .ico {
		height: 1.2rem;
		background-position: center top;
		background-repeat: no-repeat;
		background-size: auto 100%;
		background-image: url(../../image/common/19.png);
	}
	.recommend.on .ico {
		background-image: url(../../image/common/20.png);
	}
	.recommend .txt {
		margin-top: 0.15rem;
		font-size: 0.5rem;
		line-height: 1;
		color: #adadad;
	}
	.recommend .txt:after {
		content: "加入推荐";
	}
	.recommend.on .txt {
		color: #E73451;
	}
	.recommend.on .txt:after {
		content: "已推荐";
	}
	.btmShareBox {
		padding: 0 0.75rem 0 0rem;
	}
	.btmShareBox > div {
		width: 50%;
		height: 2rem;
		font-size: 0.7rem;
	}
	.btmShareBox .left {
		border-radius: 0.4rem 0 0 0.4rem;
		border: 1px solid #E73250;
		border-right: none;
		color: #E73250;
	}
	.btmShareBox .right {
		border-radius: 0 0.4rem 0.4rem 0;
		color: #FFF;
		background-image: linear-gradient(-5deg, #E73451 1%, rgba(231,50,80,0.66) 100%);
	}
	.btmShareBox img {
		margin-right: 0.25rem;
		height: 0.8rem;
		width: auto;
	}
	@media all and (max-width: 360px){
		.btmShareBox > div {
			font-size: 0.6rem;
		}
		.btmShareBox img {
			margin-right: 0.15rem;
			height: 0.75rem;
		}
	}
</style>
</head>

<body>
	<header class="aui-bar aui-bar-nav aui-bar-light" id="header">
<!--
		<div class="aui-pull-left back" tapmode onClick="api.closeWin();"></div>
		<div class="aui-title"></div>
		<div class="aui-pull-right headRightBtn" tapmode onClick=""><img src="../../image/common/06.png" alt=""></div>
-->
	</header>
	<div class="btmFix aui-flex-col aui-flex-middle aui-flex-between aui-border-t" id="footer">

	</div>

	<script type="text/x-dot-template" id="data_tpl">
		<div class="recommend {{= it.recommend_status == 2 ? 'on' : '' }}" tapmode onClick="togRecommend(this);">
			<div class="ico"></div>
			<div class="txt"></div>
		</div>
		<div class="flex-auto">
			<div class="btmShareBox aui-flex-col aui-flex-middle">
				<div class="left aui-flex-col aui-flex-middle aui-flex-center" tapmode onClick="tokouling()">
					<div><img src="../../image/common/35.png" alt=""></div>
					{{ if(getUserVip() > 1){ }}
					<div>分享赚¥{{= it.data_amount}}</div>
					{{ }else{ }}
					<div>升级VIP赚佣金</div>
					{{ } }}
				</div>
				<div class="right aui-flex-col aui-flex-middle aui-flex-center" tapmode onClick="toTaobao();">
					{{ if( it.coupon_info ){ }}
					<div><img src="../../image/common/36.png" alt=""></div>
					<div>领券购¥{{= it.coupon_info }}券</div>
					{{ }else{ }}
					<div>打开淘宝购买</div>
					{{ } }}
				</div>
			</div>
		</div>
	</script>

</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
var USER_INFO;
var GOD_INFO;
    apiready = function() {
        api.parseTapmode();
		var header = $api.byId('header');
        $api.fixStatusBar(header);
        var headerH = $api.offset(header).h;
        var footerH = $api.offset($api.byId('footer')).h;
        api.openFrame({
            name: 'product_detail_frm',
            url: 'product_detail_frm.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto',
				// marginBottom: footerH
            },
			bgColor: '#f5f5f5',
			bounces: true,
			reload: true,
            pageParam: api.pageParam
        });
		api.openFrame({
            name: 'product_detail_head_frm',
            url: 'product_detail_head_frm.html',
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: headerH
            },
			reload: true,
			bounces: false
		});

		USER_INFO = getUserinfo();
		//监听获取商品详情后 更新foot
		api.addEventListener({
			name: 'godFootUpdateEvent'
		}, function(ret, err){
			GOD_INFO = ret.value.godInfo;
			footUpdate();
		});
	};

//更新foot
function footUpdate(){
	var tpl = $$('#data_tpl').html();
	var tempFn = doT.template(tpl);
	$$('#footer').html(tempFn(GOD_INFO));
	api.parseTapmode();
}
//切换推荐状态
function togRecommend(el){
	if(!getUserId()){
		openLogin();
		return;
	}
	var _this = $$(el);
	api.ajax({
		url: BASE_URL + 'App/Article/addRecommend',
		method: 'post',
		data:{
			values: {
				userid: getUserId(),
				shop_id: GOD_INFO.shop_id
			}
		}
	},function(ret,err){
		if (ret && ret.code == 1) {
			toast(ret.msg);
			_this.toggleClass('on');
		} else {
			toast('操作失败，请稍候再试');
		};
	});
}

//打开口令页面
function tokouling(){
	if(!getUserId()){
		openLogin();
		return;
	}
	if(USER_INFO.user_vip == 1){
		api.openWin({
			name: 'gift_index_win',
			url: '../giftBag/gift_index_win.html'
		});
	}else{
		api.execScript({
			frameName: 'product_detail_frm',
			script: 'openCouling();'
		});
	}
}

//跳转淘宝
function toTaobao(){
	api.execScript({
		frameName: 'product_detail_frm',
		script: 'taobao();'
	});
}
</script>
</html>
